<!DOCTYPE html>
<html lang="en">
  <head>
    $shared/head()$
    <script>
    function validar(){ 
      if(!\$("input[name='idTurnoTemp']:checked").val()) {
        \$("#alert").show();
        return false;
      }
      return true;
    }

    function validarPaso2 (){ 
      if(\$("#observacion").val()=="") {
        \$("#alertObservacion").show();
        return false;
      }
      return true;
    }
    function irPaso2(){
        if (validar()){
          \$("#mostrarPaso").val("2");
          \$("#txtbuscar").val("");          
          \$("#idTurno").val(\$('input:radio[name=idTurnoTemp]:checked').val());
          \$("#myForm").submit();
        }
    }
    function terminar(){
        if (validarPaso2()){
          \$("#mostrarPaso").val("3");
          \$("#myForm").submit();
        }
    }
    
    </script>

    <script>
      \$(function(){
        \$(".panel-body").unhighlight().highlight("$txtbuscar$");
        \$('.input-daterange').datepicker({
            format: "dd/mm/yyyy",
            weekStart: 1,
            language: "es",
            calendarWeeks: true,
            todayHighlight: true,
            autoclose: true
        });
      });
    </script>
  </head>
  <body>
<div class="container">
$shared/header()$
    
    <div class="row">
        <div class="col-sm-3 col-md-3 sidebar">
            <span type="button" class="hidden-print">
    <span class="glyphicon glyphicon-user"></span> $usuarioConectado.Nombre$&nbsp;$usuarioConectado.Apellido$
  </span>
        $shared/menu()$
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-8 col-md-offset-0 main ">
          <ol class="breadcrumb  hidden-print">
          <li><a href="home.aspx">Inicio</a></li>
          <li class="active">Cierre de turno Historicos</li>
        </ol>
        <div class="text-right">
          <button type="button" class="btn btn-default btn-sm" onclick="window.print();">
          <span  class="glyphicon glyphicon-print" ></span> Imprimir
          </button>
        </div>
$if (mostrarExito)$
  <div class="alert alert-success" role="alert">La turno fue cerrado exitosamente!</div>
$endif$ 

$if (mostrarError)$
  <div class="alert alert-danger" role="alert">Lo sentimos ocurri&oacute; error:<br/>$error$</div>
$endif$ 
  <form method="POST" name="myForm" id="myForm">
  $if (mostrarPaso1)$
  <div id="paso1">        

  <div class="panel panel-default">
  <!-- Default panel contents -->
     <div class="alert alert-danger" id="alert" style="display:none">
      <a href="#" class="alert-link">Debe seleccionar un turno...</a>
    </div>
<!--<div class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control keyboard" placeholder="Buscar" id="txtbuscar" name="txtbuscar" value="$txtbuscar$">
        </div>
        <button type="submit" class="btn btn-default" >Buscar</button>
      </div>-->

  <div class="panel-heading hidden-print"> 
    <table>
      <tr>
        <td>
          <div class="input-daterange input-group" id="datepicker">
          <span class="input-group-addon">Desde</span>
          <input type="text" class="input-sm form-control" name="fecha_inicio" value="$fecha_inicio$" />
          <span class="input-group-addon">Hasta</span>
          <input type="text" class="input-sm form-control" name="fecha_termino" value="$fecha_termino$"/>
          </div>
        </td>
        <td>
          <input type="text" class="input-sm form-control keyboard" placeholder="Buscar" id="txtbuscar" name="txtbuscar" value="$txtbuscar$"/>
        </td>
        <td>
          <button type="submit" class="btn btn-default" >Buscar</button>
        </td>
      </tr>
    </table>
    
  </div>
  <div class="panel-body">
      <table class="table table-hover table-condensed">
        <thead>
          <tr>
            <th>&nbsp;</th>
            <th>#</th>
            <th>Nombre</th>
            <th>RUN</th>
            <th>P. de Venta</th>
            <th>Cierre Real</th>
            <th>F. Turno</th>
            <th>Estado</th>
          </tr>
        </thead>
        <tbody>
          $turnos: {t|
          <tr>
            <td><input type="radio" name="idTurnoTemp"   id="$t.Id$" name="idTurnoTemp" value="$t.Id$"></td>
            <td>$i$</td>
            <td>$t.Cajero.NombreCompleto$</td>
            <td>$t.Cajero.Rut$</td>
            <td>$t.PuntoVenta$</td>
            <td>$t.FechaCierre$</td>
            <td>$t.Cierre.FechaNegocio; format="dd/MM/yyyy"$</td>
            <td>
          $if (t.Cierre.Cuadrado)$
            <span class="label label-success"><span class="glyphicon glyphicon-ok"></span></span>
          $else$
            <span class="label label-danger"><span class="glyphicon glyphicon-thumbs-down"></span></span>
          $endif$ 
            </td>
          </tr>
          }$
        </tbody>
      </table>
    </div>
  <div class="panel-footer"> 
        <a href="#" class="btn btn-primary " onclick="irPaso2();">Mostrar detalle</a>
    </div>
  </div>
</div>
$endif$ 
$if(mostrarPaso2)$
<div id="paso2">
  <div class="alert alert-danger" id="alertObservacion" style="display:none">
      <a href="#" class="alert-link">Debe ingresar una observacion.</a>
    </div>
<div class="panel panel-default">
  <div class="panel-heading ">Reporte de Cierre de <b>$turno.Cajero.NombreCompleto$</b>.</div>
  <div class="panel-body">
      $tableHTML$
      <h3>Observaci&oacute;n al Cierre</h3>
 <div class="form-group">
            <textarea class="form-control keyboard" placeholder="Ingrese un comentario" required rows=4 id="observacion" name="observacion" readonly="readonly">$turno.Cierre.Observacion$</textarea>
      </div>
      $shared/resumen_turno()$

      $shared/comentarios_turno()$
      
    <div class="visible-print text-right">
      <br/><br/>
        <table width="80%" align="right" >
          <tr>
            <td>
              _______________________________
            </td>
            <td>&nbsp;&nbsp;&nbsp;</td>
            <td>
              _______________________________
            </td>
            <tr>

            <td>
              Supervisor
            </td>
            <td>&nbsp;&nbsp;&nbsp;</td>
            <td>
              Cajero
            </td>
          </tr>
        </table>
      </div>
  </div>
  <div class="panel-footer"> 
            <a href="home.aspx" class="btn btn-primary" >Volver</a>
  </div>
  </div>
</div>
$endif$ 

<input type="hidden" name="mostrarPaso" id="mostrarPaso" value="1">
<input type="hidden" name="idTurno"  id="idTurno" value="$turno.Id$">
</form>
      
      $shared/footer()$
      </div>
      </div>
      </div>
  </body>
</html> 